<template>
  <div class="fulltable">
    <div class="full">
    <div class="add">  
      <button class="button" @click="showAddTaskDialog">➕新增</button>  
    </div>

    <div class="search-box">  
    <el-select v-model="selectedType" placeholder="请选择任务类型" style="width: 200px; margin-right: 10px;" clearable>  
      <el-option v-for="item in taskTypeOptions" :key="item.value" :label="item.label" :value="item.value"></el-option>  
    </el-select>
      <el-input v-model="searchTitle" placeholder="搜索标题" style="width: 200px; margin-right: 10px;" clearable></el-input>  
      <el-select v-model="searchPromoter" placeholder="选择发起人" style="width: 200px; margin-right: 10px;" clearable>
        <el-option v-for="tauser in promoters" :key="tauser" :label="tauser" :value="tauser"></el-option>
      </el-select>  
    </div>
    <el-table
    :data="filteredData.slice((currentPage - 1) * pageSize, currentPage * pageSize)" 
    :height="tableHeight"
    border
    style="width: 100%">
    <el-table-column
      prop="type"
      label="任务类型"
      width="100">
    </el-table-column>
    <el-table-column
      prop="title"
      label="标题"
      width="180"
      >
    </el-table-column>
    <el-table-column
      prop="desc"
      label="描述"
      width="200">
    </el-table-column>
     <el-table-column
      prop="starttime"
      label="开始时间"
      width="180">
    </el-table-column>
    <el-table-column
      prop="promoter"
      label="发起人"
      width="120">
    </el-table-column>
    <el-table-column
      prop="deptname"
      label="部门"
      width="120">
    </el-table-column>
    <el-table-column
      prop="state"
      label="状态"
      width="80">
    </el-table-column>
      <el-table-column
      prop="priority"
      label="优先级"
      width="80">
    </el-table-column>
        <el-table-column label="操作">  
          <template slot-scope="scope">  
            <el-button type="primary" size="small" @click="viewItem(scope.row)">详情</el-button>  
            <el-button 
              type="warning" 
              size="small" 
              @click="editItem(scope.row)"
              v-if="canDelete(scope.row)">编辑</el-button>
            <el-button 
              type="danger" 
              size="small" 
              @click="deleteItem(scope.row)"
              v-if="canDelete(scope.row)">删除</el-button>  
          </template>  
        </el-table-column>  
  </el-table>
      <div class="paging">
        <el-pagination  
          @size-change="handleSizeChange"  
          @current-change="handleCurrentChange"  
          :current-page="currentPage"  
          :page-sizes="[5,10, 20, 40, 60]"  
          :page-size="pageSize"  
          :pager-count="4"  
          layout="total, sizes, prev, pager, next, jumper"  
          :total="filteredData.length">  <!-- 使用 filteredData.length -->  
        </el-pagination> 
      </div>
  </div>
    <el-dialog title="新增任务" :visible.sync="showAddDialog" width="30%">  
      <el-form :model="newTask" :rules="rules" ref="newTaskForm" label-width="80px">  
        <el-form-item label="任务类型" prop="type">  
          <el-select v-model="newTask.type" placeholder="请选择任务类型">  
            <el-option v-for="item in taskTypeOptions" :key="item.value" :label="item.label" :value="item.value"></el-option>  
          </el-select>  
        </el-form-item>  
        <el-form-item label="任务标题" prop="title">  
          <el-input v-model="newTask.title"></el-input>  
        </el-form-item>  
        <el-form-item label="任务描述" prop="desc">  
          <el-input v-model="newTask.desc"></el-input>  
        </el-form-item>  
        <el-form-item label="开始时间" prop="starttime">  
          <el-date-picker v-model="newTask.starttime" type="datetime" placeholder="请选择开始时间"></el-date-picker>  
        </el-form-item>  
        <el-form-item label="结束时间" prop="deadline">  
          <el-date-picker v-model="newTask.deadline" type="datetime" placeholder="请选择结束时间"></el-date-picker>  
        </el-form-item>  
      <el-form-item label="部门" prop="deptname" >  
        <el-select v-model="newTask.deptname" filterable placeholder="请选择部门,不选则默认发所有人" style="width:400px">  
          <el-option v-for="item in deptList" :key="item.id" :label="item.deptname" :value="item.id"></el-option>  
        </el-select>  
      </el-form-item> 
      <el-form-item label="负责人" prop="charge">  
        <el-select v-model="newTask.charge" filterable placeholder="请选择负责人" style="width:400px">  
          <el-option v-for="item in chargeList" :key="item.id" :label="item.realname" :value="item.id"></el-option>  
        </el-select>  
      </el-form-item> 
      <el-form-item label="接收人" prop="receiverList">  
        <el-select v-model="receiverList" multiple placeholder="请选择接收人，不填则视为发部门下所有人" style="width:400px">  
          <el-option v-for="item in userByDept" :key="item.id" :label="item.realname" :value="item.id"></el-option>  
        </el-select>  
      </el-form-item>
        <el-form-item label="任务状态" prop="state">  
          <el-select v-model="newTask.state" placeholder="请选择任务状态" style="width:400px">  
            <el-option v-for="item in taskStateOptions" :key="item.value" :label="item.label" :value="item.value"></el-option>  
          </el-select>  
        </el-form-item>  
        <el-form-item label="优先级" prop="priority">  
          <el-select v-model="newTask.priority" placeholder="请选择任务优先级" style="width:400px">  
            <el-option v-for="item in taskPriorityOptions" :key="item.value" :label="item.label" :value="item.value"></el-option>  
          </el-select>  
        </el-form-item>  
      </el-form>  
      <div slot="footer" class="dialog-footer">  
        <el-button @click="cancelDialog">取 消</el-button>  
        <el-button type="warning" @click="resetForm">重 置</el-button>  
        <el-button type="primary" @click="saveNewTask">确 定</el-button>  
      </div>  
    </el-dialog>
<el-dialog title="任务详情" :visible.sync="showDetailDialog" width="50%">  
  <el-form :model="selectedTask" label-width="80px">  
    <el-row>  
      <el-col :span="12">  
        <el-form-item label="任务类型">  
          <el-input v-model="selectedTask.type" disabled></el-input>  
        </el-form-item>  
      </el-col>  
      <el-col :span="12">  
        <el-form-item label="任务标题">  
          <el-input v-model="selectedTask.title" disabled></el-input>  
        </el-form-item>  
      </el-col>  
    </el-row>  
    <el-row>  
      <el-col :span="12">  
        <el-form-item label="优先级">  
          <el-input v-model="selectedTask.priority" disabled></el-input>  
        </el-form-item>  
      </el-col> 
      <el-col :span="12">  
        <el-form-item label="开始时间">  
          <el-input v-model="selectedTask.starttime" disabled></el-input>  
        </el-form-item>  
      </el-col>  
    </el-row>  
    <el-row>  
      <el-col :span="12">  
        <el-form-item label="结束时间">  
          <el-input v-model="selectedTask.deadline" disabled></el-input>  
        </el-form-item>  
      </el-col>  
      <el-col :span="12">  
        <el-form-item label="发起人">  
          <el-input v-model="selectedTask.promoter" disabled></el-input>  
        </el-form-item>  
      </el-col>  
    </el-row>  
    <el-row>  
      <el-col :span="12">  
        <el-form-item label="部门">  
          <el-input v-model="selectedTask.deptname" disabled></el-input>  
        </el-form-item>  
      </el-col>  
      <el-col :span="12">  
        <el-form-item label="负责人">  
          <el-input v-model="selectedTask.charge" disabled></el-input>  
        </el-form-item>  
      </el-col> 
    </el-row>  
    <el-row>  
      <el-col :span="12">  
        <el-form-item label="任务描述">  
          <el-input type="textarea" v-model="selectedTask.desc" disabled></el-input>  
        </el-form-item>  
      </el-col>  
      <el-col :span="12">  
        <el-form-item label="接收人">  
          <el-input type="textarea" v-model="selectedTask.recipient" disabled></el-input>  
        </el-form-item>  
      </el-col>   
    </el-row>  
    <el-row>  
       <el-col :span="12">  
        <el-form-item label="状态">  
          <el-input v-model="selectedTask.state" disabled></el-input>  
        </el-form-item>  
      </el-col>  
            <el-col :span="12">  
        <el-form-item label="评价">  
          <el-input type="textarea" v-model="selectedTask.evaluate" disabled></el-input>  
        </el-form-item>  
      </el-col>  
    </el-row>  
  </el-form>  
  <div slot="footer" class="dialog-footer">  
    <el-button @click="showDetailDialog = false">取 消</el-button>  
  </div>  
</el-dialog>
<el-dialog title="编辑任务" :visible.sync="editDialogVisible" width="30%">  
  <el-form :model="editTask"  ref="editTaskForm" label-width="80px">  
    <el-form-item label="任务类型" prop="type">  
      <div style="display: flex; align-items: center;">
        <el-select v-model="editTask.type" placeholder="请选择任务类型" style="width: 200px;">  
          <el-option v-for="item in taskTypeOptions" :key="item.value" :label="item.label" :value="item.value"></el-option>  
        </el-select>
        <span style="margin-left: 10px; color: #409EFF;">当前: {{ currentTask.type }}</span>
      </div>  
    </el-form-item>  
    <el-form-item label="任务标题" prop="title">  
      <el-input v-model="editTask.title"></el-input>  
    </el-form-item>  
    <el-form-item label="任务描述" prop="desc">  
      <el-input v-model="editTask.desc"></el-input>  
    </el-form-item>  
    <el-form-item label="开始时间" prop="starttime">  
      <el-date-picker v-model="editTask.starttime" type="datetime" placeholder="请选择开始时间"></el-date-picker>  
    </el-form-item>  
    <el-form-item label="结束时间" prop="deadline">  
      <el-date-picker v-model="editTask.deadline" type="datetime" placeholder="请选择结束时间"></el-date-picker>  
    </el-form-item>  
    <el-form-item label="部门" prop="deptname">  
      <div style="display: flex; align-items: center;">
        <el-select v-model="editTask.deptname" filterable placeholder="请选择部门" style="width: 200px;">  
          <el-option v-for="item in deptList" :key="item.id" :label="item.deptname" :value="item.id"></el-option>  
        </el-select>
        <span style="margin-left: 10px; color: #409EFF;">当前: {{ currentTask.deptname }}</span>
      </div>  
    </el-form-item> 
    <el-form-item label="负责人" prop="charge">  
      <div style="display: flex; align-items: center;">
        <el-select v-model="editTask.charge" filterable placeholder="请选择负责人" style="width: 200px;">  
          <el-option v-for="item in chargeList" :key="item.id" :label="item.realname" :value="item.id"></el-option>  
        </el-select>
        <span style="margin-left: 10px; color: #409EFF;">当前: {{ currentTask.charge }}</span>
      </div>  
    </el-form-item> 
    <el-form-item label="接收人" prop="receiverList">  
      <div style="display: flex; align-items: center;">
        <el-select v-model="editTask.receiverList" multiple placeholder="请选择接收人" style="width: 200px;">  
          <el-option v-for="item in userByDept" :key="item.id" :label="item.realname" :value="item.id"></el-option>  
        </el-select>
        <span style="margin-left: 10px; color: #409EFF;">当前:</span>
        <el-input type="textarea" v-model="currentTask.recipient" disabled style="margin-left: 10px; width: 200px;"></el-input>
      </div>  
    </el-form-item>
    <el-form-item label="任务状态" prop="state">  
      <div style="display: flex; align-items: center;">
        <el-select v-model="editTask.state" placeholder="请选择任务状态" style="width: 200px;">  
          <el-option v-for="item in edittaskStateOptions" :key="item.value" :label="item.label" :value="item.value"></el-option>  
        </el-select>
        <span style="margin-left: 10px; color: #409EFF;">当前: {{ getStateName(currentTask.state) }}</span>
      </div>  
    </el-form-item>  
    <el-form-item label="优先级" prop="priority">  
      <div style="display: flex; align-items: center;">
        <el-select v-model="editTask.priority" placeholder="请选择任务优先级" style="width: 200px;">  
          <el-option v-for="item in taskPriorityOptions" :key="item.value" :label="item.label" :value="item.value"></el-option>  
        </el-select>
        <span style="margin-left: 10px; color: #409EFF;">当前: {{ getPriorityName(currentTask.priority) }}</span>
      </div>  
    </el-form-item>  
  </el-form>  
  <div slot="footer" class="dialog-footer">  
    <el-button @click="editDialogVisible = false">取 消</el-button>  
    <el-button type="primary" @click="saveEditTask">确 定</el-button>  
  </div>  
</el-dialog>
  </div>
</template>

<script>
import {getTaskList,addTask,deleteTaskById,getTaskDetailById,updateTask} from '@/api/task';
import {getChargeList,getUserByDeptId,getAdminList} from '@/api/user';
import {getDeptList} from '@/api/dept';
import {jwtDecode} from 'jwt-decode';
import {addLog} from '@/api/log';
export default {
  data(){
    return {
      logItem:{
              mn:'',
              opn:'',
              res:''
      },
      taskData:[],
        currentPage: 1,  
        pageSize: 5  ,
        tableHeight: 350,  
        maxTableHeight: 700, // 最大高度 600px  
        minTableHeight: 350,
        showAddDialog: false, // 是否显示新增对话框  
        showDetailDialog: false, // 控制查看详情对话框的显示  
        selectedTask: {}, // 存储选中的任务信息  
        selectedType: null, // 用于树形选择框的绑定  
        searchTitle: '',  // 用于存储搜索标题  
        searchPromoter: '',  // 用于存储搜索发起人  
        newTask: { // 新任务信息  
          type: '',  
          title: '',  
          desc: '',  
          starttime: '',  
          deadline:'',
          promoter: '',  
          deptname: '',  
          state: '',  
          priority: '',
          receiverList:[],
          charge:''  
        },
        receiverList: [],  
        rules: { // 表单验证规则  
          type: [  
            { required: true, message: '请选择任务类型', trigger: 'change' }  
          ],  
          title: [  
            { required: true, message: '请输入任务标题', trigger: 'blur' }  
          ],  
          desc: [  
            { required: true, message: '请输入任务描述', trigger: 'blur' }  
          ],  
          starttime: [  
            { required: true, message: '请选择开始时间', trigger: 'change' }  
          ],  
          deadline: [  
            { required: true, message: '请选择结束时间', trigger: 'change' }  
          ],  
          promoter: [  
            { required: true, message: '请选择发起人', trigger: 'change' }  
          ],
          state: [  
            { required: true, message: '请选择任务状态', trigger: 'change' }  
          ],  
          priority: [  
            { required: true, message: '请选择任务优先级', trigger: 'change' }  
          ],
          charge: [  
            { required: true, message: '请选择负责人', trigger: 'change' }  
          ]
        },  
        taskTypeOptions: [ // 任务类型选项  
          { label: '公事', value: '公事' },  
          { label: '私事', value: '私事' }
        ],  
        taskStateOptions: [ // 任务状态选项  
          { label: '待办', value: '1' },  
          { label: '进行中', value: '2' },  
          { label: '已完成', value: '3' },  
        ],  
        edittaskStateOptions: [ // 任务状态选项  
          { label: '待办', value: '1' },  
          { label: '进行中', value: '2' },  
          { label: '已完成', value: '3' },  
        ],  
        taskPriorityOptions: [ // 任务优先级选项  
          { label: '低', value: '3' },  
          { label: '中', value: '2' },  
          { label: '高', value: '1' }  
        ],
        chargeList:[],
        deptList:[],
        userByDept:[],
        adminList:[],
        userRole: this.getUserRole(), // 获取用户角色
        myId: this.getUserId(), // 获取用户ID
        userDeptId: this.getUserDeptId(), // 获取用户部门ID
        promoters:[],
        editDialogVisible: false,
        editTask: {
          id: '',
          type: '',
          title: '',
          desc: '',
          starttime: '',
          deadline: '',
          deptname: '',
          charge: '',
          receiverList: [],
          state: '',
          priority: ''
        },
        currentTask: {}, // 用于存储当前编辑任务的原始信息
        baseAdminList: []
    }
  },
computed: {  
  filteredData() {  
    return this.taskData.filter(task => {  
      // 根据选择的任务类型过滤  
      const matchesType = this.selectedType ? task.type === this.selectedType : true;  

      // 根据输入的标题搜索过滤  
      const matchesTitle = task.title.includes(this.searchTitle);  

      // 根据输入的发起人搜索过滤  
      const matchesPromoter = task.promoter.includes(this.searchPromoter);  

      // 返回所有条件都匹配的任务  
      return matchesType && matchesTitle && matchesPromoter;  
    });  
  }  
}  , 
  created(){
    getTaskList().then(response=>{
      this.taskData = response.data
      this.promoters = [...new Set(this.taskData.map(task => task.promoter))]
      this.calculateTableHeight() 
      console.log(response.data)
    }).catch(error =>{
      console.log(error)
      this.tableHeight = this.minTableHeight 
    })

    this.getCharges()
    this.getDepts()
    this.getAdmins()
  },
  watch:{
  currentPage() {  
    this.calculateTableHeight()  
  },  
  pageSize() {  
    this.calculateTableHeight()  
  },
  'newTask.deptname'(newVal) {  
    console.log("这是一个部门Id：",newVal);
    if(newVal){
    this.getUserByDept(newVal);  
    this.handleChargeList(newVal);
    }
  }, 
  'editTask.deptname'(newVal) {  
    console.log("这是一个部门Id：",newVal);
    if(newVal){
    this.getUserByDept(newVal);  
    this.handleChargeList(newVal);
    }
  } 
  },
  methods:{
    handleSizeChange(val) {  
      this.pageSize = val;  
      this.currentPage = 1;  
      this.logItem.mn = "handleSizeChange";
      this.logItem.opn = "改变每页显示的任务数量-任务管理";
      this.logItem.res = "true";
      addLog(this.logItem);
    },  
    handleCurrentChange(val) {  
      this.currentPage = val;  
      this.logItem.mn = "handleCurrentChange";
      this.logItem.opn = "改变页码-任务管理";
      this.logItem.res = "true";
      addLog(this.logItem);
    },  
calculateTableHeight() {  
  const currentPageData = this.filteredData.slice((this.currentPage - 1) * this.pageSize, this.currentPage * this.pageSize);  
  let height = (currentPageData.length + 1) * 60;  // 每行60px  
  this.tableHeight = Math.max(this.minTableHeight, Math.min(height, this.maxTableHeight));  
},
  getAdmins(){
    getAdminList().then(response =>{
      this.adminList = response.data
    })
  },

  showAddTaskDialog() {  
    this.showAddDialog = true  
  },  
  saveNewTask() {  
    this.$refs.newTaskForm.validate((valid) => {  
      if (valid) {  
        // 调用接口保存新任务  
        this.newTask.receiverList = this.receiverList 
        addTask(this.newTask).then(response => {  
          console.log("接收人",this.newTask.receiverList)
          console.log('保存新增任务:', this.newTask);   
          this.logItem.mn = "saveNewTask";
          this.logItem.opn = "新增任务";
          this.logItem.res = "true";
          addLog(this.logItem);
          //刷新页面
          window.location.reload()  
          //关闭对话框
          this.showAddDialog = false;  
          this.$message.success('新任务添加成功')  
        }).catch(error => {  
          console.log(this.newTask)
          this.logItem.mn = "saveNewTask";
          this.logItem.opn = "新增任务";
          this.logItem.res = "false";
          addLog(this.logItem);
          // console.error(error)  
          this.$message.error('新任务添加失败')  
        })  
      } else {  
        return false  
      }  
    })  
  },
    getCharges(){
      getChargeList().then((response) => {  
        console.log("管理员们",response.data)
        this.chargeList = response.data;  
        this.baseAdminList = response.data
      });  
    },
    getDepts(){
      getDeptList().then((response) => {  
        console.log(response.data)
        this.deptList = response.data;  
      });  
    },
      handleDeptChange(deptId) {  
        this.getUserByDept(deptId); 
        this.handleChargeList(deptId); 
      },
      handleChargeList(deptId){
        // 过滤 chargeList，只包含符合条件的用户  
        this.chargeList = this.baseAdminList.filter(user =>   
            user.role === 1 || (user.role === 2 && user.deptId === deptId)  
        );  
      },
       getUserByDept(deptId) {  
        getUserByDeptId(deptId).then((response) => {  
          this.userByDept = response.data;  
        });  
      },
  deleteItem(row) {  
  this.$confirm('确定要删除此任务吗?', '警告', {  
    confirmButtonText: '确定',  
    cancelButtonText: '取消',  
    type: 'warning'  
  }).then(() => {  
    // 调用删除 API  
    deleteTaskById(row.id).then(response => {  
      // 从 taskData 中移除已删除的项  
      this.taskData = this.taskData.filter(item => item.id !== row.id);  
      this.logItem.mn = "deleteItem";
      this.logItem.opn = "删除任务";
      this.logItem.res = "true";
      addLog(this.logItem);
      this.$message.success('任务删除成功');  
      window.location.reload()  
    }).catch(error => {  
      console.error(row);  
      this.logItem.mn = "deleteItem";
      this.logItem.opn = "删除任务";
      this.logItem.res = "false";
      addLog(this.logItem);
      this.$message.error('任务删除失败');  
    });  
  }).catch(() => {  
    this.$message.info('已取消删除');  
  });  
},viewItem(row) {  
    
    getTaskDetailById(row.id).then((response)=>{
      this.showDetailDialog = true; // 打开查看详情对话框  
      console.log(response.data)
      this.selectedTask = response.data;
      this.logItem.mn = "viewItem";
      this.logItem.opn = "查看任务详情-任务管理";
      this.logItem.res = "true";
      addLog(this.logItem);
    }).catch(()=>{
      console.error(row);  
      this.logItem.mn = "viewItem";
      this.logItem.opn = "查看任务详情-任务管理";
      this.logItem.res = "false";
      addLog(this.logItem);
      this.$message.error('任务查看失败');  
    })
  },   
  resetForm() {
    this.$refs.newTaskForm.resetFields();
    this.newTask = {
      type: '',
      title: '',
      desc: '',
      starttime: '',
      deadline: '',
      promoter: '',
      deptname: '',
      state: '',
      priority: '',
      receiverList: [],
      charge: '',
      reviewer: ''
    };
    this.receiverList = []; // 重置接收人列表
  },
  cancelDialog() {
    this.$refs.newTaskForm.clearValidate(); // Clear validation
    this.showAddDialog = false;
    this.resetForm();
  },
  // 获取用户角色
  getUserRole() {
    const token = localStorage.getItem('token');
    if (token) {
      const decodedToken = jwtDecode(token);
      return decodedToken.role;
    }
    return null;
  },

  // 获取用户ID
  getUserId() {
    const token = localStorage.getItem('token');
    if (token) {
      const decodedToken = jwtDecode(token);
      return decodedToken.userId;
    }
    return null;
  },

  // 获取用户部门ID
  getUserDeptId() {
    const token = localStorage.getItem('token');
    if (token) {
      const decodedToken = jwtDecode(token);
      return decodedToken.deptId;
    }
    return null;
  },

  // 判断是否可以删除
  canDelete(row) {
    if (this.userRole === 'SUPERMAN') {
      return true; // 超级管理员可以删除所有
    } else if (this.userRole === 'MANAGER') {
      // 部门管理员可以删除自己发起的或本部门的
      return row.promoterid === this.myId || row.deptid === this.userDeptId;
    } else if (this.userRole === 'NORMAL') {
      // 普通用户只能删除自己发起的
      return row.promoterid === this.myId;
    }
    return false;
  },
  editItem(row) {
    // 获取任务详情并打开编辑弹窗
    getTaskDetailById(row.id).then((response) => {
      this.currentTask = response.data;
      // 清空编辑表单的值
      this.editTask = {
        id: response.data.id,
        type: '',
        title: response.data.title,
        desc: response.data.desc,
        starttime: response.data.starttime,
        deadline: response.data.deadline,
        deptname: '',
        charge: '',
        receiverList: [],
        state: '',
        priority: ''
      };
      
      if (response.data.deptid) {
        this.getUserByDept(response.data.deptid);
      }
      
      this.editDialogVisible = true;
    }).catch(error => {
      console.error('获取任务详情失败:', error);
      this.$message.error('获取任务详情失败');
    });
  },

  saveEditTask() {
    this.$refs.editTaskForm.validate((valid) => {
      if (valid) {
        updateTask(this.editTask).then(response => {
          this.$message.success('任务信息更新成功');
          this.editDialogVisible = false;
          this.logItem.mn = "saveEditTask";
          this.logItem.opn = "编辑任务信息";
          this.logItem.res = "true";
          addLog(this.logItem);
          // 刷新页面
          window.location.reload();
        }).catch(error => {
          console.error('更新失败:', error);
          this.logItem.mn = "saveEditTask";
          this.logItem.opn = "编辑任务信息";
          this.logItem.res = "false";
          addLog(this.logItem);
          this.$message.error('任务信息更新失败');
        });
      } else {
        return false;
      }
    });
  },

  // 获取状态名称
  getStateName(state) {
    const stateMap = {
      '0': '待审批',
      '1': '审批通过',
      '3':'已完成'
    };
    return stateMap[state] || state;
  },

  // 获取优先级名称
  getPriorityName(priority) {
    const priorityMap = {
      '1': '高',
      '2': '中',
      '3': '低'
    };
    return priorityMap[priority] || priority;
  }
  } 
}
</script>

<style lang="less" scoped>
.fulltable{
  margin-top: 20px;
  height: 700px;

}
.full{
  height: 800px;
  margin: 0;
  padding: 0;
  background: pink;
  padding-top:10px;
  margin-left: 20px;
  margin-right: 20px;
  border-radius: 10px;
  flex: 1;
}
.add{
  padding: 10px;
}
/deep/.el-table .cell {  
  color: black;
}  
.button{
  background: #788fd3;
  color: white;
}
.paging{
  margin: 0;
  padding: 0;
  padding-top:10px;
  margin-left: 20px;
  margin-right: 20px;
  border-radius: 10px;
  flex: 1;

  /deep/ .el-pagination {
    display: flex;  
    justify-content: flex-end;  
  }
}
</style>